<template>
  <svg aria-hidden="true" class="svg-icon" :style="{fill: color}" :width="props.size" :height="props.size">
    <use :xlink:href="symbolId" />
  </svg>
</template>

<script setup lang="ts">
import { computed } from 'vue'

const props = defineProps({
  prefix: {
    type: String,
    default: 'icon'
  },
  name: {
    type: String,
    default: null
  },
  color: {
    type: String,
    default: null
  },
  size: {
    type: String,
    default: '1em'
  }
})

const symbolId = computed(() => `#${ props.prefix }-${ props.name }`)
</script>

<style lang="less" scoped>
.svg-icon {
  fill: currentColor;
}
</style>
